package com.xiyu.service.repository.nurse.plan;

import com.xiyu.service.model.nurse.item.NurseItemFetcher;
import com.xiyu.service.model.nurse.plan.NursePlanDetail;
import com.xiyu.service.model.nurse.plan.NursePlanDetailFetcher;
import com.xiyu.service.model.nurse.plan.NursePlanDetailTable;
import org.babyfish.jimmer.spring.repository.JRepository;

import java.util.List;

public interface NursePlanDetailRepository extends JRepository<NursePlanDetail, Long> {
    NursePlanDetailTable nursePlanDetailTable = NursePlanDetailTable.$;

    default List<NursePlanDetail> findByPlanId(Long planId){
        return sql().createQuery(nursePlanDetailTable)
                .where(nursePlanDetailTable.planId().eq(planId))
                .select(nursePlanDetailTable.fetch(NursePlanDetailFetcher.$.allTableFields().item(NurseItemFetcher.$.allTableFields())))
                .execute();
    };
}